# Importing Data
PAKISTAN<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "Y1:Y239")

# Checking the Imported Data
View(PAKISTAN)
# Creating Time Series Data
Pakistan_ts <- ts(PAKISTAN, start=c(2000,1), end=c(2018,11), frequency=12)
# Viewing and Checking the Created Time Series Data
Pakistan_ts
sum(is.na(Pakistan_ts))
library(forecast)
Pakistan_ts <- tsclean(Pakistan_ts)
Pakistan_ts

# Identification: Plotting the Time Series Data
plot(Pakistan_ts)

# Estimating the appropriate model
Pakistan_ts_model <- auto.arima(Pakistan_ts)
Pakistan_ts_model

# Forecasting
options(max.print=1000000)
Pakistan_ts_forecast <- forecast (Pakistan_ts_model, level=c(95), h=265)
plot(Pakistan_ts_forecast)
Pakistan_ts_forecast             

# Exporting
write.table(Pakistan_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/PAKISTAN_TSA.csv", sep=",")
